---
title: "SD-03 | UC-03: Avoid Front Obstacle"
---
sequenceDiagram
    participant CTR as :Controller
    participant MU as :MovementUnit
    participant LS as left:ObstacleSensor
    participant RS as right:ObstacleSensor

    CTR->>CTR: avoidFrontObstacle()
    activate CTR

    CTR->>MU: stop()
    activate MU
    deactivate MU

    CTR->>CTR: checkSideObstacles()
    CTR->>LS: isObstacleDetected()
    LS-->>CTR: boolean
    CTR->>RS: isObstacleDetected()
    RS-->>CTR: boolean

    alt LEFT or RIGHT is free
        CTR->>MU: turn(freeDirection)
        activate MU
        deactivate MU
        CTR->>MU: moveForward()
        activate MU
        deactivate MU
    else Both LEFT and RIGHT blocked
        CTR->>CTR: avoidAllDirectionObstacle()
    end

    deactivate CTR
